﻿using Balloonerds.Algebra;

namespace RayTracer
{
    public class Intersection
    {
        public Thing Object { get; protected set; }
        public Ray Ray { get; protected set; }
        public double Distance { get; protected set; }
        public Vector Point { get; protected set; }
        public Vector SurfaceNormal
        {
            get
            {
                return Object.GetSurfaceNormal(Point);
            }
        }

        public Ray ReflectedRay
        {
            get
            {
                return new Ray()
                {
                    Origin = Point,
                    Direction = Vector.Reflect(Ray.Direction, Object.GetSurfaceNormal(Point))
                };
            }
        }

        public Intersection(Thing obj, Ray ray, Vector point, double distance)
        {
            Object = obj;
            Ray = ray;
            Point = point;
            Distance = distance;
        }
    }
}

